#pragma once
#include <stdint.h>
#define USE_QGL		0

#if USE_QGL
#define OGLWidget QGLWidget
#include <QOpenGLWidget>
#include <QOpenGLFunctions>
#else
#define OGLWidget GLWidget
#define GLEW_STATIC
#include <GL/glew.h>
#include <GL/wglew.h>
#endif

#define FIELDOFFSET(TYPE, MEMBER) (int)(&(((TYPE*)0)->MEMBER))

char* ReadAllBytes(const char* url);

struct Vertex
{
	float position[3];
	float normal[3];
	float texcoord[2];
};
struct Mesh
{
	uint32_t indexCount;
	uint32_t *indices;
	uint32_t vertexCount;
	Vertex *vertices;
	uint32_t faceCont;
};

Mesh* LoadObjMesh(const char* url, bool isDropRepeat);

GLuint CreateVAO();

GLuint CreateVBO(const void* data, const GLsizeiptr size, GLenum usage);

GLuint CreateEBO(const void* data, const GLsizeiptr size, GLenum usage);

void SaveBMP24(const char* filename, int width, int height, void *buffer);